// pages/help/help.js
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    status:{},
    id:"",
    items:[{}],
    count:{},
    check:{},
    dir:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var _this = this
    //载入国内或者国外数据
    if (app.globalData.formType==0){
    wx.request({
      url: app.globalData.apiurl +"api/index/category",
      method:"GET",
      data:{
        formType:app.globalData.formType
      },
      header: {
        'content': "json"
      },
      success(e){
        console.log(e)
          _this.setData({
            items:e.data.category,
            status: e.data.status,
            check: e.data.check,
            count: e.data.count
          })
        var ddir = _this.data.dir
        for (var i = 1; i <= _this.data.count; i++) {
          ddir[i - 1] = "1";
        }
        _this.setData({
          dir: ddir
        })
      }
    })
    }else{
      wx.request({
        url: app.globalData.apiurl + "api/index/category",
        method: "GET",
        data: {
          formType: app.globalData.formType
        },
        header: {
          'content': "json"
        },
        success(e) {
          _this.setData({
            items: e.data.acategory,
            status: e.data.status,
            check: e.data.check,
            count: e.data.count
          })
          var ddir = _this.data.dir
          for (var i = 1; i <= _this.data.count; i++) {
            ddir[i - 1] = "1";
          }
          _this.setData({
            dir: ddir
          })
        }
      })
    }
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },

  /**
   * 点击显示详情
   */
  //点击显示详情
  bindDetail:function(e){
    var index = e.currentTarget.dataset.status;
    var stt = this.data.status;
    var ddir = this.data.dir;
    console.log(e);
    if(stt[index]=='none'){
      for(var i=1;i<=this.data.count;i++){
        stt[i-1]="none";
        ddir[i-1]="1"
      }
      stt[index] = '';
      ddir[index] = "2"
    }else{
      stt[index] = 'none';
      ddir[index] = "1"
    }
    this.setData({
      status: stt,
      dir:ddir
    });
  },
bindradio:function(e){
    var _this = this
    _this.setData({
      id:e.detail.value
    })
},


  bindNext: function (e){
    
    var formid = e.detail.formId;
    if(this.data.id==""){
      wx.showToast({
        title: '请选择公证业务',
        icon: 'none'
      })
      return false;
    }
    wx.request({
      url: app.globalData.apiurl + "api/index/setformids",
      method: "GET",
      data: {
        uid: app.globalData.userInfo.user_id,
        formid: formid
      },
      header: {
        'content': "json"
      },
      success(e) {

      }
    });
    wx.navigateTo({
      url: '../basefrom/basefrom?id='+this.data.id,
    })
  }
})